package com.leenmvc.core.security.entity.core;

import com.leenmvc.core.annotation.DbInfo;
import com.leenmvc.core.annotation.FillField;
import com.leenmvc.core.annotation.PrimaryKey;
import com.leenmvc.core.annotation.TableField;
import com.leenmvc.core.annotation.validator.Foreign;
import com.leenmvc.core.annotation.validator.groups.AddGroup;
import com.leenmvc.core.annotation.validator.groups.UpdateGroup;
import com.leenmvc.core.base.BaseEntity;
import com.leenmvc.core.security.dao.core.SysMenuDao;

import java.util.Date;

/**
 * 角色菜单关系
 *
 * @author leen
 * @since 1.0.0
 */
@DbInfo(value = "sys_role_menu", comment = "角色菜单")
public class SysRoleMenu extends BaseEntity {

    @PrimaryKey
    private Long id;

    /**
     * 角色ID
     */
//    @Foreign(message = "角色信息不存在", value = SysRoleDao.class, groups = {AddGroup.class, UpdateGroup.class})
//    @Uniqueness(linkFields = {"menuId"}, groups = {AddGroup.class, UpdateGroup.class})
    private Long roleId;

    @TableField(false)
    @FillField(entity = SysRole.class, outField = "name", inField = "roleId")
    private String roleName;
    /**
     * 菜单ID
     */
    @Foreign(message = "菜单信息不存在", value = SysMenuDao.class, groups = {AddGroup.class, UpdateGroup.class})
    private Long menuId;

    @TableField(false)
    @FillField(entity = SysMenu.class, outField = "url", inField = "menuId")
    private String menuName;

    @TableField(false)
    private Long[] menuList;


    protected Long creator;

    protected Date createDate;

    public Long getCreator() {
        return creator;
    }

    public void setCreator(Long creator) {
        this.creator = creator;
    }

    public Date getCreateDate() {
        return createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }

    public Long getMenuId() {
        return menuId;
    }

    public void setMenuId(Long menuId) {
        this.menuId = menuId;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    public String getMenuName() {
        return menuName;
    }

    public void setMenuName(String menuName) {
        this.menuName = menuName;
    }

    public Long[] getMenuList() {
        return menuList;
    }

    public void setMenuList(Long[] menuList) {
        this.menuList = menuList;
    }
}
